package com.hspedu.newData.dmsxl.树.搜索树;

import com.hspedu.newData.dmsxl.ds.TreeNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-07 
 * @Version: 1.0
 */

public class LC700二叉搜索树中的搜索 {

    public TreeNode searchBST(TreeNode root, int val) {

        if (root == null) return null;

        if (root.val == val){
            return root;
        } else if (root.val > val) {
            return searchBST(root.left,val);
        }else {
            return searchBST(root.right,val);
        }
    }
}
